package com.zxy.emailserver;

import com.zxy.common.EmailRemoteCall;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;

/**
 * @author zhangxuyuan
 * @version 1.0
 * @date 2021/1/27
 */
@Service
public class EmailService implements EmailRemoteCall {

    @Autowired
    private JavaMailSender sender;

    @Async
    @Override
    public void send(String email, String code) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("1559761282@qq.com");
        message.setTo(email);
        message.setSubject("这是验证码");
        message.setText(code);
        sender.send(message);
    }
}
